package com.shujia.akka.actors

import akka.actor.{Actor, ActorRef, ActorSystem, Props}

object OuYangFengActor extends App {
  private val actorSystem: ActorSystem = ActorSystem("sheDiao")
  private val gouJinRef: ActorRef = actorSystem.actorOf(Props[GuoJinActor], "gouJin")

  //  private val ouYangRef: ActorRef = actorSystem.actorOf(Props[OuYangFengActor], "ouYang")
  private val ouYangRef: ActorRef = actorSystem.actorOf(Props(new OuYangFengActor(gouJinRef)), "ouYang")
  ouYangRef ! "开打"
}

class OuYangFengActor(gouJinRef: ActorRef) extends Actor {
  override def receive: Receive = {
    case "开打" => {
      println("欧阳锋：看我蛤蟆功，郭靖小贼..")
      gouJinRef ! "蛤蟆功"
    }

    case "降龙十八掌" => {
      println("欧阳锋：欧阳克放蛇")
      sender() ! "蛇"
    }
  }
}
